package com.account.manager;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.account.manager.filter.AccessFilter;

@SpringBootApplication
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class MappRunApplication {

	public static void main(String[] args) {

		SpringApplication.run(MappRunApplication.class, args);
	}

	@Bean
	public FilterRegistrationBean accessFilterRegistrationBean() {
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		registrationBean.setName("accessFilter");
		AccessFilter greetingFilter = new AccessFilter();
		registrationBean.setFilter(greetingFilter);
		registrationBean.setOrder(1);
		List<String> urlList = new ArrayList<String>();
		urlList.add("/*");
		registrationBean.setUrlPatterns(urlList);
		return registrationBean;
	}
}